package com.yjd.comm.util;

import java.util.regex.Pattern;



/**
 * 正则表达式
 */
public class CommonRegexParrern {

	private static final String yyyy_MM_dd_reg = "(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29)";
	
	private static  String HH_mm_ss_reg = "(([0-1]{1}[0-9]{1})|([2]{1}[0-4]{1}))([:])((([0-5]{1}[0-9]{1})|([6]{1}[0]{1})))([:])(((([0-5]{1}[0-9]{1})|([6]{1}[0]{1}))))";
	
	private static  String splitor = " ";
	
	public static boolean match_yyyy_MM_dd(String val){
		if(StringUtil.isEmpty(val)){
			return false;
		}
		Pattern p = Pattern.compile(yyyy_MM_dd_reg);
		return p.matcher(val).matches();
	}
	
	public static boolean match_HH_mm_ss(String val){
		if(StringUtil.isEmpty(val)){
			return false;
		}
		Pattern p = Pattern.compile(HH_mm_ss_reg);
		return p.matcher(val).matches();
	}
	
	
	public static boolean match_yyyy_MM_dd_HH_mm_ss(String val){
		String []s= val.trim().split(splitor);
		if(s.length==2){
			return match_yyyy_MM_dd(s[0])&&match_HH_mm_ss(s[1]);
		}else{
			return false;
		}
	}
	
}